package org.musicsweet.controller;

import org.musicsweet.anotation.AuthReq;
import org.musicsweet.entity.MusicAlbum;
import org.musicsweet.result.ResultData;
import org.musicsweet.service.MusicAlbumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 专辑Controller
 */
@RestController
@RequestMapping("/musicAlbum")
public class MusicAlbumController {


    @Autowired
    private MusicAlbumService musicAlbumService;

    /**
     * 根据id查询专辑
     * @param musicAlbum
     * @return
     */
    @AuthReq
    @RequestMapping("/getMusicAlbumById")
    public ResultData<MusicAlbum> getMusicAlbumById(@RequestBody MusicAlbum musicAlbum) {
        return musicAlbumService.getMusicAlbumById(musicAlbum);
    }

    /**
     * 多条件查询专辑
     * @param musicAlbum
     * @return
     */
    @AuthReq
    @RequestMapping("/getMusicAlbumList")
    public ResultData<List<MusicAlbum>> getMusicAlbumList(@RequestBody MusicAlbum musicAlbum) {
        return musicAlbumService.getMusicAlbumList(musicAlbum);
    }


    /**
     * 添加专辑
     * @param musicAlbum
     * @param token
     * @return
     */
    @RequestMapping("/addMusicAlbum")
    public ResultData addMusicAlbum(@RequestBody MusicAlbum musicAlbum,String token) {
        return musicAlbumService.addMusicAlbum(musicAlbum,token);
    }


    /**
     * 修改专辑
     * @param musicAlbum
     * @param token
     * @return
     */
    @RequestMapping("/updateMusicAlbum")
    public ResultData updateMusicAlbum(@RequestBody MusicAlbum musicAlbum,String token) {
        return musicAlbumService.updateMusicAlbum(musicAlbum,token);
    }


    /**
     * 删除专辑
     * @param musicAlbum
     * @return
     */
    @RequestMapping("/delMusicAlbum")
    public ResultData delMusicAlbum(@RequestBody MusicAlbum musicAlbum) {
        return musicAlbumService.delMusicAlbum(musicAlbum);
    }

}
